using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace ConsoleApplication2.Models.Mapping
{
    public class ItmCategMap : EntityTypeConfiguration<ItmCateg>
    {
        public ItmCategMap()
        {
            // Primary Key
            this.HasKey(t => t.ID);

            // Properties
            this.Property(t => t.NAME)
                .IsRequired()
                .HasMaxLength(100);

            this.Property(t => t.File_Primary_Key)
                .HasMaxLength(10);

            this.Property(t => t.code)
                .HasMaxLength(10);

            this.Property(t => t.ChartCode)
                .HasMaxLength(20);

            this.Property(t => t.IC_DC_DrawMode)
                .HasMaxLength(20);

            this.Property(t => t.IC_DC_Hint)
                .HasMaxLength(200);

            this.Property(t => t.IC_DC_TextSymbol)
                .HasMaxLength(10);

            this.Property(t => t.IC_DC_PositionCode)
                .HasMaxLength(20);

            // Table & Column Mappings
            this.ToTable("ItmCateg");
            this.Property(t => t.ID).HasColumnName("ID");
            this.Property(t => t.NAME).HasColumnName("NAME");
            this.Property(t => t.TYPE).HasColumnName("TYPE");
            this.Property(t => t.File_Primary_Key).HasColumnName("File Primary Key");
            this.Property(t => t.PROTECTED).HasColumnName("PROTECTED");
            this.Property(t => t.code).HasColumnName("code");
            this.Property(t => t.ChartCode).HasColumnName("ChartCode");
            this.Property(t => t.Modifier).HasColumnName("Modifier");
            this.Property(t => t.LabReportOrder).HasColumnName("LabReportOrder");
            this.Property(t => t.IC_DC_UserDefinied).HasColumnName("IC_DC_UserDefinied");
            this.Property(t => t.IC_DC_DrawMode).HasColumnName("IC_DC_DrawMode");
            this.Property(t => t.IC_DC_Order).HasColumnName("IC_DC_Order");
            this.Property(t => t.IC_DC_Hint).HasColumnName("IC_DC_Hint");
            this.Property(t => t.IC_DC_TextSymbol).HasColumnName("IC_DC_TextSymbol");
            this.Property(t => t.IC_DC_PositionCode).HasColumnName("IC_DC_PositionCode");
            this.Property(t => t.IC_DC_Index).HasColumnName("IC_DC_Index");

            // Relationships
            this.HasRequired(t => t.ItemType)
                .WithMany(t => t.ItmCategs)
                .HasForeignKey(d => d.TYPE);

        }
    }
}
